package com.example.football.mapper;

import com.example.football.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ScheduleMapper {
    @Select("select * from schedule where hometeam in (select liketeam from peopleliketeam where peopleid=#{peopleid}) or guestteam in (select liketeam from peopleliketeam where peopleid=#{peopleid})")
    List<Schedule> findSchedule(Peopleliketeam peopleid);

    @Select("select * from schedule where id in (select scheduleid from peopleschedule where peopleid=#{id})")
    List<Schedule> findPeopleSchedule(People id);

    @Select("select id from peopleschedule where peopleid=#{peopleid} and scheduleid=#{scheduleid}")
    Integer findPeoplescheduleid(Peopleschedule peopleschedule);

    @Delete("delete from peopleschedule where peopleid=#{peopleid} and scheduleid=#{scheduleid}")
    void  deletePeopleschedule(Peopleschedule peopleschedule);

    @Insert("insert into peopleschedule(peopleid,scheduleid) values(#{peopleid},#{scheduleid})")
    void insertPeopleschedule(Peopleschedule peopleschedule);

    @Select("select * from schedule where league=#{league}")
    List<Schedule> findScheduleByLeague(Schedule schedule);
}
